package edu.sdjzu.exam.mapper;

import edu.sdjzu.exam.domain.auth.Role;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

import org.apache.ibatis.annotations.*;



@Mapper
public interface RoleMapper {
    @Select("SELECT * FROM Roles WHERE role_id = #{roleId}")
    Role findById(Long roleId);

    @Select("SELECT * FROM Roles WHERE role_name = #{roleName}")
    Role findByName(String roleName);

    @Insert("INSERT INTO Roles (role_name, description) VALUES (#{roleName}, #{description})")
    @Options(useGeneratedKeys = true, keyProperty = "roleId")
    void insert(Role role);

    @Update("UPDATE Roles SET role_name = #{roleName}, description = #{description} WHERE role_id = #{roleId}")
    void update(Role role);

    @Delete("DELETE FROM Roles WHERE role_id = #{roleId}")
    void delete(Long roleId);

    @Select("SELECT * FROM Roles")
    List<Role> findAll();
}
